AR	=ar
AS	=as --32
LD	=ld -m elf_i386
LDFLAGS	=-s -x
CC	=gcc -march=i386
CFLAGS	=-Wall -g -m32 -fstrength-reduce -fno-stack-protector -fomit-frame-pointer -no-pie -fno-pic -I../include
CPP	=gcc -E -nostdinc -I../include

.c.s:
	$(CC) $(CFLAGS) \
	-S -o $*.s $<
.s.o:
	$(AS) -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) \
	-c -o $*.o $<

OBJS  = sched.o system_call.o traps.o asm.o fork.o panic.o printk.o vsprintf.o sys.o exit.o signal.o mktime.o

kernel.o: $(OBJS)
	$(LD) -r -o kernel.o $(OBJS)
	sync

clean:
	rm -f *.o *.a
	for i in *.c;do rm -f `basename $$i .c`.s;done
	(cd chr_drv; make clean)
	(cd blk_drv; make clean)
	(cd math; make clean)

exit.s exit.o: exit.c ../include/errno.h ../include/signal.h \
	../include/sys/types.h ../include/sys/wait.h ../include/linux/sched.h \
	../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
	../include/linux/kernel.h ../include/linux/tty.h ../include/termios.h \
	../include/asm/segment.h
fork.s fork.o: fork.c ../include/errno.h ../include/linux/sched.h \
	../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
	../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
	../include/asm/segment.h ../include/asm/system.h
mktime.s mktime.o: mktime.c ../include/time.h
panic.s panic.o: panic.c ../include/linux/kernel.h ../include/linux/sched.h \
	../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
	../include/linux/mm.h ../include/signal.h 
printk.s printk.o : printk.c ../include/stdarg.h ../include/stddef.h \
  ../include/linux/kernel.h 
sched.s sched.o: sched.c ../include/linux/sched.h ../include/linux/head.h \
	../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
	../include/signal.h ../include/linux/kernel.h ../include/linux/sys.h \
	../include/linux/fdreg.h ../include/asm/system.h ../include/asm/io.h \
	../include/asm/segment.h
signal.s signal.o: signal.c ../include/linux/sched.h ../include/linux/head.h \
  ../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
  ../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h
sys.s sys.o: sys.c ../include/errno.h ../include/linux/sched.h \
  ../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
  ../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \
  ../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h \
  ../include/sys/times.h ../include/sys/utsname.h
traps.s traps.o: traps.c ../include/string.h ../include/linux/head.h \
	../include/linux/sched.h ../include/linux/fs.h ../include/sys/types.h \
	../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
	../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h
vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h 